Quick demo¶

In [1]:
from pathlib import Path
from mrimate.mrimate import MRImateExperiment
/home/rserial/.cache/pypoetry/virtualenvs/mrimate-GazfC78H-py3.9/lib/python3.9/site-packages/numpy/_core/getlimits.py:545: UserWarning: Signature b'\x00\xd0\xcc\xcc\xcc\xcc\xcc\xcc\xfb\xbf\x00\x00\x00\x00\x00\x00' for <class 'numpy.longdouble'> does not match any known type: falling back to type probe function.
This warnings indicates broken support for the dtype!
  machar = _get_machar(dtype)

Data directory¶

In [2]:
filepath = Path("/mnt/c/Users/Raque/Dropbox/TUHH/projects/MRI3T_data_analysis/Aug-20240812T081905Z-001/Aug/HBR-09/")
filename = "ha_20240809_171936_19_3_wipdelrecpos" 

Experiment loading¶

In [3]:
experiment = MRImateExperiment(filepath, filename)
experiment.load()
experiment.describe()
Experiment Details:
- Examination Name: hannah-bubble-reacto
- Type: 2D
- Date: August 09, 2024

Scan Information:
- Technique: TFE
- Dimension: 2D
- Resolution: 176x88 pixels
- Slices: 1
- Dynamics: 10
- Flow Encoding: Yes
- Diffusion Encoding: No

Calculating velocity (only working for 1d for now)¶

In [4]:
experiment.calculate_velocity()

Accessing spin density and phase/velocity images (in case of velocity encoding)¶

In [5]:
spin_density = experiment.get_spin_density()
phase = experiment.get_phase()
velocity = experiment.get_velocity()

Exporting data to hdf5¶

Exports spin density, and phase/velocity in case of flow encoded experiments. Didn't check the hdf5 files are exported ok.

In [6]:
experiment.export_to_hdf5(filepath=Path('.'), filename='experiment_data.h5') 
Data exported to experiment_data.h5 successfully.

Plotting proton density¶

You can choose two different plot types: "dynamics" or "slices". Either way you can choose the slice or dynamic id you want to plot. 3d plots are not possible right now.

In [7]:
experiment.plot_proton_density(plot_type='slices', dynamic_idx=-1, rotate_xy_axes=True)
In [8]:
experiment.plot_proton_density(plot_type='dynamics', slice_idx=0, rotate_xy_axes=True)

Plotting velocity data¶

In [9]:
experiment.plot_velocity(plot_type="dynamics", slice_idx=0, rotate_xy_axes=True)

Additional functionalities: accessing experiment parameters¶

  • Print all parameters:
In [10]:
experiment.display_parameters()
Note: The ImageInformation list contains more than one item. Displaying only last dynamic
MRIExperiment_Philips(
    PatientName='ha',
    ExaminationName='hannah-bubble-reacto',
    ProtocolName='WIP DelRec - pos',
    ExaminationDateTime='2024.08.09 / 17:19:36',
    SeriesDataType='Image   MRSERIES',
    AcquisitionNr=19,
    ReconstructionNr=3,
    ScanDuration=12.5,
    MaxNumberOfCardiacPhases=1,
    MaxNumberOfEchoes=1,
    MaxNumberOfSlicesLocations=1,
    MaxNumberOfDynamics=10,
    MaxNumberOfMixes=1,
    PatientPosition='HFS',
    PreparationDirection='RL',
    Technique='TFE',
    ScanResolution=[176, 88],
    ScanMode='2D',
    RepetitionTime=6.17,
    Fov=(350.0, 350.0, 15.0),
    WaterFatShift=1.14,
    AngulationMidslice=(0.0, -21.078, 0.0),
    OffCentreMidslice=(0.0, 0.0, 0.0),
    FlowCompensation=0,
    Presaturation=0,
    PhaseEncodingVelocity=(0.0, 0.0, 20.0),
    Mtc=0,
    Spir=0,
    EpiFactor=1,
    DynamicScan=1,
    Diffusion=0,
    DiffusionEchoTime=0.0,
    MaxNumberOfDiffusionValues=1,
    MaxNumberOfGradientOrients=1,
    NumberOfLabelTypes=0,
    ImageInformation=[
        ImageInformation_Philips(
            SliceNumber=1,
            EchoNumber=1,
            DynamicScanNumber=10,
            CardiacPhaseNumber=1,
            ImageTypeMr=3,
            ScanningSequence=4,
            IndexInRecFile=19,
            ImagePixelSize=16,
            ScanPercentage=50,
            ReconResolution=(288, 288),
            RescaleIntercept=-20.0,
            RescaleSlope=0.00977,
            WindowCenter=0,
            WindowWidth=40,
            ImageAngulation=(0.0, -21.08, 0.0),
            ImageOffcentre=(0.0, 0.0, 0.0),
            SliceThickness=15.0,
            SliceGap=0.0,
            ImageDisplayOrientation=0,
            SliceOrientation=2,
            FmriStatusIndication=0,
            ImageTypeEdEs=2,
            PixelSpacing=(1.22, 1.22),
            EchoTime=3.8,
            DynScanBeginTime=21.01,
            TriggerTime=0.0,
            DiffusionBFactor=0.0,
            NumberOfAverages=1,
            ImageFlipAngle=2.0,
            CardiacFrequency=0,
            MinimumRrInterval=0,
            MaximumRrInterval=0,
            TurboFactor=88,
            InversionDelay=0.0,
            DiffusionBValueNumber=1,
            GradientOrientationNumber=1,
            ContrastType='7',
            DiffusionAnisotropyType='0',
            Diffusion=(0.0, 0.0, 0.0),
            LabelType=1
        )
    ]
)
  • Experiment parameters can be accessed from the class.
In [11]:
experiment.parameters.PhaseEncodingVelocity
Out[11]:
(0.0, 0.0, 20.0)